<template>
  <div>
    <div class="incolumn_countr">
      <div class="search-box">
        <hy-search
          ref="query"
          :searchTitle="searchTitle"
          v-model="searcher"
          :button="{btnShowBy3:true}"
          :buttonText="{btnNameBy3:'新增设备'}"
          :col="6"
          @search="getlist(0)"
          @clickbybtn3="jump"
        ></hy-search>
      </div>
    </div>
    <div class="table-box">
      <template>
        <el-table
          :data="tableData"
          style="width: 100%;background-color:#fff"
          :cell-style="rowClass"
          :header-cell-style="headClass"
          :max-height="620"
          stripe
        >
          <el-table-column label="序号" type="index" align="center" width="100"></el-table-column>
          <el-table-column prop="equipmentNumber" label="设备编号" align="center"></el-table-column>
          <el-table-column prop="name" label="设备名称" align="center"></el-table-column>
          <el-table-column prop="address" label="设备地址" align="center"></el-table-column>
          <el-table-column prop="state" label="状态" align="center"></el-table-column>
          <el-table-column label="操作" align="center">
            <template slot-scope="scope">
              <el-button
                size="small"
                type="warning"
                v-show="scope.row.paixu>0"
                @click="xiangqing(scope.row.id,0)"
              >审核</el-button>
              <el-button size="small" type="primary" @click="xiangqing(scope.row.id,1)">详情</el-button>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </div>
    <template>
      <el-pagination
        background
        layout="prev, pager, next"
        :current-page="current"
        :page-size="pagesize"
        @current-change="handleCurrentChange"
        :total="total"
        style="text-align：center"
      ></el-pagination>
    </template>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  data () {
    return {
      total: 1,
      current: 1,
      pagesize: 10,
      searchTitle: [
        {
          type: "input",
          name: "customProductName",
          label: "输入搜索",
          placeholder: "请输入设备名称",
          prop: "customProductName"
        },
        {
          type: "date2",
          name: "issuanceDate",
          label: "输入时间",
          placeholder: "请选择输入时间",
          prop: "issuanceDate"
        }
      ],
      searcher: {
        customProductName: "",
        customProductNo: "",
        issuanceDate: ""
      },
      tableData: [],
      creater: ""
    };
  },
  created () {
    this.creater = JSON.parse(localStorage.getItem("message")).Id;
    this.getlist(0)
  },
  methods: {
    // 分页
    handleCurrentChange (e) {
      this.getlist(e - 1);
    },
    // 表头样式设置
    headClass () {
      return "text-align:center;";
    },
    // 表格样式设置
    rowClass () {
      return "text-align: center;";
    },
    xiangqing (e, shows) {
      this.$router.push({ path: "./Routinemaintenanceaddequipmentxiangq", query: { e: e, shows: shows } });
    },
    jump () {
      this.$router.push({ path: "/Routinemaintenanceaddequipment" });
    },
    getlist (page) {
      let start = ""; let end = "";
      if (this.searcher.issuanceDate != null && this.searcher.issuanceDate != "") { start = this.searcher.issuanceDate[0]; end = this.searcher.issuanceDate[1]; }
      let obj = {
        key: this.searcher.customProductName ? this.searcher.customProductName : "",
        start: start,
        end: end,
        pn: page,
        PerPageSize: this.pagesize
      };
      var objs = JSON.stringify(obj);
      let the = { index: 9, jsondata: objs }
      axios.post("/apis/AdministrationManage.asmx/GetData", the).then(({ data }) => {
        var list = eval('(' + data.d + ')');
        console.log(list);
        this.total = list.count;
        this.tableData = list.data;
      });
    },
  }
};
</script>

<style lang="scss" scoped>
@import '@/assets/scss/base.scss';
@import '@/assets/scss/search.scss';
.container {
  background-color: $bgcolor;
}
.incolumn_countr {
  width: 97%;
}
.top-box {
  width: 100%;
  height: 100px;
  padding-left: 1%;
  padding-top: 10px;
  //   border: 1px solid $red;
  background-color: $white;
  margin-bottom: 20px;
}

.table-box {
  width: 98%;
  height: 620px;
  //   border: 1px solid $red;
  margin: 0 auto;
}
.sea-box {
  width: 90%;
  float: left;
  margin-left: 1%;
  // border: 1px solid red;
}
.hy_search {
  margin-top: 10px;
}
.sear-box {
  width: 8%;
  float: left;
  margin-left: 0.5%;
  //  border: 1px solid red;
}
.el-pagination {
  margin-top: 20px;
  text-align: center;
}
.btn-box {
  width: 30%;
  height: 60px;
  overflow: hidden;
  // border: 1px solid $red;
  float: right;
  margin-right: 2%;
}
.btn {
  float: right;
  margin-top: 10px;
}
</style>